﻿using CSRedis;

namespace MedicalPCTerminal.Read.API
{
    public static class MyRedisHelper
    {
        private readonly static CSRedisClient redisClient = new CSRedisClient("127.0.0.1:6379");

        /// <summary>
        /// 写入
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static async Task<bool> Set(string key, object value)
        {
            var result = await redisClient.SetAsync(key, value);
            return result;
        }
        /// <summary>
        /// 读取
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static async Task<string> Get(string key)
        {
            var result = await redisClient.GetAsync(key);
            return result;
        }
        /// <summary>
        /// 移除
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static async Task<long> Del(string key)
        {
            var result = await redisClient.DelAsync(key);
            return result;
        }


        public static async Task<T> GetAsync<T>(string key)
        {
            RedisHelper.Initialization(redisClient);
            var result = await RedisHelper.GetAsync<T>(key);
            return result;
        }
    }
}
